package transaction.xml;

import java.util.Arrays;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class TransactionTest {
	
	@Autowired
	private ClassPathXmlApplicationContext cpxac = new ClassPathXmlApplicationContext("transaction_annotation.xml");
	BookShopDao bookShopDao = (BookShopDao) cpxac.getBean("bookShopDao");
	BookShopService bookShopService = (BookShopService) cpxac.getBean("bookShopService");
	Cashier cashier = (Cashier) cpxac.getBean("cashier");
	
	@Test
	public void transactionTest2(){
		cashier.purchase(1001, Arrays.asList(1001,1002));
	}
	
	@Test
	public void transactionTest(){
		bookShopService.purchase(1001, 1001);
	}
	
	@Test
	public void test3(){
		bookShopDao.updateUserAccount(1001, 1000);
	}
	
	@Test
	public void test2(){
		bookShopDao.updateBookStock(1001);
	}

	@Test
	public void test1() {
		System.out.println(bookShopDao.getBookPriceById(1001));
	}

}
